package com.example.children.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.example.children.Util.JwtUtil;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

//    @Bean
//    public FilterRegistrationBean<JwtTest> jwtFilter() {
//        System.out.println("FilterRegistrationBean------拦截器设置");
//        FilterRegistrationBean<JwtTest> registrationBean = new FilterRegistrationBean<>();
//        registrationBean.setFilter(new JwtTest());
//        registrationBean.addUrlPatterns("/*");  // 设置需要过滤的 URL 路径，可以是全局路径
//        // 排除某些不需要过滤的路径
////        registrationBean.addUrlPatterns("/login", "/register");
//        return registrationBean;
//    }



        @Override
        public void addCorsMappings(CorsRegistry registry) {
            System.out.println("WebConfig---------路由设置");
            registry.addMapping("/**")
                .allowedOrigins("http://localhost:8080")
                    .allowedMethods("GET", "POST", "PUT", "DELETE")
                    .allowedHeaders("*");
        }






}

//@Configuration
//public class WebConfig implements WebMvcConfigurer {
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        System.out.println("WebConfig");
//        registry.addMapping("/**")
////                .allowedOrigins("http://localhost:8080", "http://localhost:63342")
//                .allowedMethods("GET", "POST", "PUT", "DELETE")
//                .allowedHeaders("*");
//    }
//}
